package com.aaa.service.scl.impl;

import com.aaa.dao.scl.PlanSclDao;
import com.aaa.dao.view.ViewsDao;
import com.aaa.entity.system.PageEnty;
import com.aaa.entity.scl.PlanScl;
import com.aaa.service.scl.PlanSclService;
import com.aaa.utils.MyRandom;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 测试计划scl(PlanScl)表服务实现类
 *
 * @author makejava
 * @since 2022-08-30 21:17:59
 */
@Service
public class PlanSclServiceImpl implements PlanSclService {
    @Autowired
     PlanSclDao planSclDao;
    @Autowired
    ViewsDao viewsDao;
    /**
     * @create by: Teacher马
     * @description:  分页排序 功能
     * @create time:  
     
     * @return 
    */
    @Override
    public Page queryAllPlanSclPage(PageEnty pageEnty, PlanScl planScl) {
        PageHelper.startPage(pageEnty.getPage(),pageEnty.getLimit(),pageEnty.orderBy());
        List<Map<String, Object>> mapList = planSclDao.queryAllPlanSclPage(planScl);
        Page page= (Page) mapList;
        return page;
    }

    /**
     * @create by: Teacher马
     * @description:  添加 随机六位数
     * @create time:

     * @return
     */
    @Override
    public boolean savePlanScl(PlanScl planScl) {
        List<Integer> integers = viewsDao.queryView();
        int myRan = MyRandom.myRan(integers);
        planScl.setTestCode(myRan);
        return planSclDao.savePlanScl(planScl);
    }
    /**
     * @create by: Teacher马
     * @description:  删除
     * @create time:

     * @return
     */
    @Override
    public boolean deletePlanScl(int[] id) {
        return planSclDao.deletePlanScl(id);
    }

    /**
     * @create by: Teacher马
     * @description:  修改
     * @create time:

     * @return
     */
    @Override
    public boolean updatePlanScl(PlanScl planScl) {
        return planSclDao.updatePlanScl(planScl);
    }

    /**
     * @create by: Teacher马
     * @description:  检查重复名
     * @create time:

     * @return
     */
    @Override
    public boolean repetitionName(PlanScl planScl) {
        Integer integer = planSclDao.repetitionName(planScl);
        if (integer>0){
            return false;
        }
        return true;
    }

    @Override
    public List<PlanScl> queryAll() {
        return planSclDao.queryAll();
    }
}
